package com.piedra.htmlparser;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.htmlparser.Parser;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.tags.ImageTag;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;

public class MyHtmlParser {

	public static void main(String[] args) throws FileNotFoundException, IOException, ParserException {
		
		String html = IOUtils.toString(new FileInputStream("src/webCont.txt"));
		
		Parser parser = new Parser();
		
		parser.setInputHTML(html);
		
		NodeList imageTags = parser.parse(new NodeClassFilter(ImageTag.class));
		
		for(int i=0; i<imageTags.size(); i++){
			ImageTag imageTag = (ImageTag)imageTags.elementAt(i);
			String imageUrl = imageTag.getImageURL();
			System.out.println(imageUrl);
		}
		
	}
	
	
}
